package edu.just.pet.service.impl;

import com.github.pagehelper.PageHelper;
import edu.just.pet.dao.UserDao;
import edu.just.pet.entity.User;
import edu.just.pet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceimpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public List<User> getUserListByPage(User user) {
        if(user.getPage() != null && user.getLimit() != null) {
            PageHelper.startPage(user.getPage(), user.getLimit());
        }
        return userDao.getUserListByPage(user);
    }


    @Override
    public Integer deleteUser(User user) {
        return userDao.deleteUser(user);
    }

    @Override
    public Integer deleteUserList(List<User> userList) {
        return userDao.deleteUserList(userList);
    }

    @Override
    public Integer addUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public Integer updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public User check(User user) {
        return userDao.getUserByUserName(user);
    }

    @Override
    public User getUserInfoById(User user) {
        return userDao.getUserInfoById(user);
    }
}
